package pages;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

import java.util.concurrent.TimeUnit;

/**
 * Created by Mikhail.Chub on 05/06/2014.
 */
public class PageManager {
    public WebDriver driver;
    public String baseURL;

    private HomePage homePage;
    private ComparisonPage comparisonPage;

    //Constructor
    public PageManager() {
        driver = new FirefoxDriver();
        baseURL = "http://rozetka.com.ua/";
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        driver.manage().window().maximize();
    }

    public void stop () {
        driver.quit();
    }

    // Lazy initialization of pages
    public HomePage getHomePage() {
        if (homePage == null) {
            homePage = new HomePage(this);
        }
        return homePage;
    }

    public ComparisonPage getComparisonPage() {
        if (comparisonPage == null) {
            comparisonPage = new ComparisonPage(this);
        }
        return comparisonPage;
    }
}
